package com.fw.web.controller.system;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.fw.annotation.Log;
import com.fw.core.controller.BaseController;
import com.fw.core.domain.AjaxResult;
import com.fw.enums.BusinessType;
import com.fw.system.admin.domain.TbVipLevel;
import com.fw.system.admin.service.ITbVipLevelService;
import com.fw.utils.poi.ExcelUtil;
import com.fw.core.page.TableDataInfo;

/**
 * 会员等级字典Controller
 * 
 * @author xxx
 * @date 2021-12-03
 */
@RestController
@RequestMapping("/admin/vip_level")
public class TbVipLevelController extends BaseController
{
    @Autowired
    private ITbVipLevelService tbVipLevelService;

    /**
     * 查询会员等级字典列表
     */
    @PreAuthorize("@ss.hasPermi('admin:vip_level:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbVipLevel tbVipLevel)
    {
        startPage();
        List<TbVipLevel> list = tbVipLevelService.selectTbVipLevelList(tbVipLevel);
        return getDataTable(list);
    }

    /**
     * 导出会员等级字典列表
     */
    @PreAuthorize("@ss.hasPermi('admin:vip_level:export')")
    @Log(title = "会员等级字典", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TbVipLevel tbVipLevel)
    {
        List<TbVipLevel> list = tbVipLevelService.selectTbVipLevelList(tbVipLevel);
        ExcelUtil<TbVipLevel> util = new ExcelUtil<TbVipLevel>(TbVipLevel.class);
        return util.exportExcel(list, "vip_level");
    }

    /**
     * 获取会员等级字典详细信息
     */
    @PreAuthorize("@ss.hasPermi('admin:vip_level:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(tbVipLevelService.selectTbVipLevelById(id));
    }

    /**
     * 新增会员等级字典
     */
    @PreAuthorize("@ss.hasPermi('admin:vip_level:add')")
    @Log(title = "会员等级字典", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbVipLevel tbVipLevel)
    {
        return toAjax(tbVipLevelService.insertTbVipLevel(tbVipLevel));
    }

    /**
     * 修改会员等级字典
     */
    @PreAuthorize("@ss.hasPermi('admin:vip_level:edit')")
    @Log(title = "会员等级字典", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbVipLevel tbVipLevel)
    {
        return toAjax(tbVipLevelService.updateTbVipLevel(tbVipLevel));
    }

    /**
     * 删除会员等级字典
     */
    @PreAuthorize("@ss.hasPermi('admin:vip_level:remove')")
    @Log(title = "会员等级字典", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(tbVipLevelService.deleteTbVipLevelByIds(ids));
    }
}
